/**
 * 
 */
package leetCode;

/**
 * @author zhong
 *
 */
public class ComplementofBase10Integer {
	public int bitwiseComplement(int N) {
		String nString = Integer.toBinaryString(N);
		StringBuilder newStr = new StringBuilder(nString.length());
		for (int i = 0; i < nString.length(); i++) {
			if (nString.charAt(i) == '0') {
				newStr.append('1');
			} else
				newStr.append('0');
		}
		return Integer.parseInt(newStr.toString(), 2);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
